{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import sys\n",
    "import re\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    handler = sys.stdin\n",
    "    for line in handler:\n",
    "        if not line:\n",
    "            continue\n",
    "        terms = line.strip().split(\" \")\n",
    "        for i in terms:\n",
    "            print(i)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import sys\n",
    "import re\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    handler = sys.stdin\n",
    "    word_dict = {}\n",
    "    for line in handler:\n",
    "        if not line:\n",
    "            continue\n",
    "        terms = line.strip().split(\" \")\n",
    "        for i in terms:\n",
    "            if i in word_dict:\n",
    "                word_dict[i] += 1\n",
    "            else:\n",
    "                word_dict[i] = 1\n",
    "\n",
    "    for j in word_dict:\n",
    "        print(j, word_dict[j])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
